import Vue from 'vue'
import VueRouter from 'vue-router'
import home from "@/views/home";
import user from "@/views/user";
import course from "@/views/course"
import relation from "@/views/relation"
import reward from "@/views/reward"
import courseResult from "@/views/course/courseResult";
import relationResult from "@/views/relation/relationResult";
import rewardResult from "@/views/reward/rewardResult";
import login from "@/views/login";
Vue.use(VueRouter)
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {path: '/',name: 'login',component: login},
  {
    path: '/home',
    name: 'home',
    component: home,
    redirect:'/user',
    children:[
      {path: '/user',name: 'user',component: user},
      {path: '/course',name:'course',component: course},
      {path: '/courseResult',name:'courseResult',component: courseResult},
      {path: '/relation',name:'relation',component: relation},
      {path: '/relationResult',name:'relationResult',component: relationResult},
      {path: '/reward',name:'reward',component: reward},
      {path: '/rewardResult',name:'rewardResult',component: rewardResult}
    ]
  },
]

const router = new VueRouter({
  routes
})

export default router
